package com.amit.hibernate;

import java.util.List;


public class HibernateCustomerDAO implements CustomerDAO {

	@Override
	public List<Customer> getAllCustomers() {
		
		String hql="from Customer c";
		List<Customer> list=HibernateTemplate.findList(hql);
		
		return list;
	}

	@Override
	public List<Customer> getCustomersByCity(String city) {
		
		String hql="from Customer c where c.city=?";
		List<Customer> list=HibernateTemplate.findList(hql, city);
		return list;
		
	}

	@Override
	public List<Customer> getCustomersByCity(String city, int start, int total) {
		String hql="from Customer c where c.city=?";
		List<Customer> list=HibernateTemplate.findList(hql, start,total,city);
		
		return list;
	}

	@Override
	public List<Customer> getCustomersByCardType(String cardType) {
		
		String hql="from Customer c where c.cardType=?";
		List<Customer> list=HibernateTemplate.findList(hql, cardType);
		
		return list;
	}

	@Override
	public List<Customer> getCustomersByCardType(String string, int start,
			int total) {
		
		String hql="from Customer c where c.cardType=?";
		List<Customer> list=HibernateTemplate.findList(hql, start, total, string);
		return list;
	}

	@Override
	public List<Customer> getCustomersByBal(double d) {
		
		String hql="from Customer c where c.cardBal=?";
		List<Customer> list=HibernateTemplate.findList(hql, d);
		
		return list;
	}

	@Override
	public List<Customer> getCustomersByBal(int bal, int start, int total) {
		String hql="from Customer c where c.cardBal=?";
		List<Customer> list=HibernateTemplate.findList(hql, start, total, bal);
		return list;
	}

	@Override
	public List<Customer> getCustomersBStatus(String status) {
		String hql="from Customer c where c.status=?";
		List<Customer> list=HibernateTemplate.findList(hql, status);
		
		return list;
	}

	@Override
	public List<Customer> getCustomersBStatus(String status, int start,
			int total) {
		String hql="from Customer c where c.status=?";
		List<Customer> list=HibernateTemplate.findList(hql,start,total,status);
		
		return list;
	}

	@Override
	public List<Customer> getCustomersByName(String cname) {
		String hql="from Customer c where c.cname=?";
		List<Customer> list=HibernateTemplate.findList(hql, cname);
		
		return list;
	}

	@Override
	public List<Customer> getCustomers(String city, String cardType) {
		
		String hql="from Customer c where c.city=? and c.cardType=?";
		List<Customer> list=HibernateTemplate.findList(hql, city,cardType);
		
		return list;
	}

	@Override
	public List<Customer> getCustomers(String city, String cardType,
			String status) {
		String hql="from Customer c where c.city=? and c.cardType=? and c.status=?";
		List<Customer> list=HibernateTemplate.findList(hql, city,cardType,status);
		
		return list;
	}

	@Override
	public Customer getCustomersByEmail(String email) {
		String hql="from Customer c where c.email=?";
		Customer c=(Customer) HibernateTemplate.findObject(hql, email);
		return c;
	}

	@Override
	public Customer getCustomersByCardNo(int ccno) {
		
		String hql="from Customer c where c.cardNo=?";
		Customer c=(Customer) HibernateTemplate.findObject(hql, ccno);
		return c;
	}

}
